<?php
namespace statistics\utils;

require_once (substr ( __DIR__, 0, strpos ( __DIR__, 'statistics' ) + 10 ) . DIRECTORY_SEPARATOR . 'includes.php');

//PHPOutputInterceptor
class PHPScriptExecutor{

	static function getScriptOutput($path, $print = FALSE)
	{
		global $gCurrentOrganization;
		global $g_root_path;
		global $gL10n;
		global $gLayout;
		global $gDb;
		global $gValidLogin;
		global $gCurrentUser;
		global $gCurrentSession;
		global $gPreferences;
		
		ob_start();
	
		if( is_readable($path))
		{
			try {
				include $path;
			} catch (Exception $e) {
				throw \Exception('Could not execute PHP-Script: '.$path);
			}
			
		}
		else
		{
			throw \Exception('Could not execute PHP-Script: '.$path);
		}
	
		if( $print == FALSE ){
			$obContents = ob_get_contents();
			ob_end_clean();
			return $obContents;
		}else{
			echo ob_get_flush();
		}
	}
	
	static function reinitializeAllGlobals(){
		foreach ($GLOBALS as $key => $value){
			
		}
	}
	
}

?>


